#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time       :   18:53
# Author     : Y4
# Site       : 
# File       : 02 异常-抛出异常.py
# Software   : PyCharm

'''
如果这个方法有人调用,则需要抛出异常,让调用者去处理
抛出异常  raise
'''

def reg():
    username = "yaomin"
    if len(username) < 8:
        raise Exception('用户名不能低于8位')
    else:
        print(username)

try:
    reg()
except Exception as err:
    print(err)